var app = new Vue({
  el: '#index',
  data() {
    return {
      msg: 'index',
      headerList1: [],
      bannerImage: '',
      index: 0,
      homePageFloor: [],
      //楼层详情
      info: [],
      normalProductData: [],
      newsContent: [],
      engage: [],
      introduction: [],
      joinMessage: []
    }
  },
  created() {
    this.getHeaderList()
    this.getHomePageFloor()
  },
  methods: {
    getHeaderList() {
      var storage = window.sessionStorage

      var c = storage.getItem('headerList')

      if (!c) {
        axios
          .get('system/service/viewMenu/findAll')
          .then(res => {
            this.headerList1 = res.data.data
            this.bannerImage = this.headerList1[this.index].bgImg
            storage.setItem('headerList', JSON.stringify(this.headerList1))
          })
          .catch(err => {
            console.error(err)
          })
      } else {
        this.headerList1 = JSON.parse(c)
        this.bannerImage = this.headerList1[this.index].bgImg
      }
    },
    //获取楼层信息
    getHomePageFloor() {
      axios
        .get('company/service/homePageFloor/findAll')
        .then(res => {
          this.homePageFloor = res.data.data
          //根据楼层列表获取楼层详细数据
          this.homePageFloor.forEach(item => {
            this.getHomePageFloorInfoByType(item.type)
          })
        })
        .catch(err => {
          console.error(err)
        })
    },
    getHomePageFloorInfoByType(floortype) {
      axios
        .get('company/service/homePageFloor/type/' + floortype)
        .then(res => {
          //1：产品,2:新闻,3:招聘,4:关于,5:合作
          switch (floortype) {
            case 1:
              this.normalProductData = res.data.data
              break
            case 2:
              this.newsContent = res.data.data
              break
            case 3:
              this.engage = res.data.data
              break
            case 4:
              this.introduction = res.data.data
              break
            case 5:
              this.joinMessage = res.data.data
              break
          }
        })
        .catch(err => {
          console.error(err)
        })
    }
  }
})
